package com.fenghuajueli.libbasecoreui.baseswitch;

import com.fenghuajueli.libbasecoreui.listener.BaseCallBackListener;
import com.fenghuajueli.lib_net.common.RetrofitUtils;

import io.reactivex.Observer;
import io.reactivex.disposables.Disposable;

/**
 * 将所有的接口请求做成工具类 直接调用,每个接口都需要传入当前界面的生面周期监听管理类
 */
public class SwitchRequest {


    /**
     * 获取开关值
     *
     * @param baseCallBackListener
     */
    public static void getSwitchKey(String appId, final BaseCallBackListener<String> baseCallBackListener) {
        baseCallBackListener.onHandlerStart();
        RetrofitUtils.getRetrofitStringBuilder(SwitchNetConstants.BASE_SWITCH_KEY_URL).build()
                .create(KeyService.class)
                .getKeys(appId)
                .subscribe(new Observer<String>() {
                    @Override
                    public void onSubscribe(Disposable d) {

                    }

                    @Override
                    public void onNext(String data) {
                        baseCallBackListener.onSuccess(data);
                    }

                    @Override
                    public void onError(Throwable e) {
                        baseCallBackListener.onFailed(e.toString());
                    }

                    @Override
                    public void onComplete() {

                    }
                });
    }


}
